package easier.websocket;

import java.net.URI;
import java.util.Map;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.handshake.ServerHandshake;

public class WebSocketClientImpl extends WebSocketClient {

    public WebSocketClientImpl( URI serverUri ) {

        super( serverUri );
    }

    public WebSocketClientImpl( URI serverUri, Draft protocolDraft ) {

        super( serverUri, protocolDraft );
    }

    public WebSocketClientImpl( URI serverUri, Map< String, String > httpHeaders ) {

        super( serverUri, httpHeaders );
    }

    public WebSocketClientImpl( URI serverUri, Draft protocolDraft, Map< String, String > httpHeaders ) {

        super( serverUri, protocolDraft, httpHeaders );
    }

    public WebSocketClientImpl( URI serverUri, Draft protocolDraft, Map< String, String > httpHeaders, int connectTimeout ) {

        super( serverUri, protocolDraft, httpHeaders, connectTimeout );
    }

    @Override
    public void onOpen( ServerHandshake handshakedata ) {

        System.out.println( "client:连接已打开" );
    }

    @Override
    public void onMessage( String message ) {

        System.out.println( "client:收到消息: " + message );
    }

    @Override
    public void onClose( int code, String reason, boolean remote ) {

        System.out.println( "client:连接已关闭" );
    }

    @Override
    public void onError( Exception ex ) {

        ex.printStackTrace();
    }
}
